package com.csdj.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * Author : 今晚几点睡_Ada
 * Date: 2022/8/16
 * Time: 9:57
 * 注:
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean  //配置了swagger 的 docket的bean 实例
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //enable  是否启动swagger2
                .enable(true)
                .groupName("今晚几点睡Ada")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.csdj.controller"))
                .build();
    }

    //配置swagger信息 apiInfo
    private ApiInfo apiInfo() {
        //作者信息
        Contact contact = new Contact("今晚几点睡Ada", "http//www.lovol.club/", "2421312133@qq.com");
        return new ApiInfo("SwaggerAPI By Ra",
                "今晚几点睡Ada",
                "s1.0",
                "http//www.lovol.club/",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());

    }
}
